# 找出大于【小于】某数值的最左或者最右的数据的索引


# 找出大于等于N的最左边位置索引
def half_search_most_index(li, num):
    l = 0
    r = len(li) - 1
    most_index = -1
    while l <= r:
        mid_index = (l+r) // 2
        if li[mid_index] < num:
            l = mid_index + 1
        # elif li[mid_index] == num:
        #     most_index = mid_index
        else:
            most_index = mid_index
            r = mid_index - 1
    return most_index


if __name__ == '__main__':
    li = [1, 1, 3, 3, 9, 11, 13, 15, 17, 19]
    result = half_search_most_index(li, 1)
    print(result)
